<template>
	<HyCard title="专业信息">
		<HyForm :hyFormDefault="hyFormDefault" :hyFormConfig="hyFormConfig" :hyFormFields="hyFormFields" ref="hyFormRef" />
	</HyCard>
</template>
<script setup lang="ts">
import HyForm from '/@/components/HyForm/index.vue';
import HyCard from '/@/components/HyCard/index.vue';
import { useDict } from '/@/hooks/dict';

const formType: string = inject('formType', 'submit');

// 定义字典
const { industry_fields, professional_fields } = useDict('industry_fields', 'professional_fields');
//配置基本信息表单
const hyFormFields = computed(() => {
	return {
		industryFieldsArr: {
			label: '擅长行业领域',
			type: 'select',
			required: true,
			options: industry_fields.value,
			multiple: true,
			multipleLimit: 3,
		},
		professionalFieldsArr: {
			label: '擅长专业领域',
			required: true,
			multipleLimit: 3,
			type: 'select',
			options: professional_fields.value,
			multiple: true,
		},
		avoidanceUnitsArr: {
			label: '回避单位',
			type: 'select',
			allowCreate: true,
			defaultFirstOption: true,
			multiple: true,
		},
		recognitionRewards: {
			label: '表彰奖励',
			type: 'textarea',
			maxlength: 200,
		},
		direction: {
			label: '擅长方向',
			type: 'textarea',
			maxlength: 200,
		},
		professionalTitle: {
			label: '',
			type: 'input',
			hidden: true,
		},
		professionalTitleFiles: {
			label: '职称证明',
			type: 'upload',
			fileType: ['.rar', '.zip', '.doc', '.pdf', '.jpg', '.jpeg', '.png'],
			fileSize: 200,
		},
		otherProof: {
			label: '',
			type: 'input',
			hidden: true,
		},
		otherProofFiles: {
			label: '其他证明资料',
			type: 'upload',
			fileType: ['.rar', '.zip', '.doc', '.pdf', '.jpg', '.jpeg', '.png'],
			fileSize: 200,
		},
	};
});

const hyFormRef = ref();
//动态表单配置
const hyFormConfig = computed(() => {
	return {
		labelWidth: '120px',
		type: formType,
	};
});
const props = defineProps({
	detailData: {
		type: Object,
		default: () => {
			return {};
		},
	},
});
const hyFormDefault = ref({});
watch(
	() => props.detailData,
	(nv1) => {
		hyFormDefault.value = nv1;
	},
	{ immediate: true }
);
const check = async () => {
	const result = await hyFormRef.value.check();
	if (result) return true;
	return false;
};
const getData = () => {
	return hyFormRef.value.hyForm;
};
defineExpose({ getData, check });
</script>
<style scoped lang="scss"></style>
